package com.gege.hmily.account.service.impl;

import com.gege.hmily.account.mapper.AccountMapper;
import com.gege.hmily.account.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author gechenpeng
 * @date 2021-05-30
 */
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    private final AccountMapper accountMapper;

    @Autowired(required = false)
    public AccountServiceImpl(AccountMapper accountMapper) {
        this.accountMapper = accountMapper;
    }

    @Override
    public void pay(String userId, BigDecimal amount) {
        int count = accountMapper.deduct(userId, amount);
        log.info("pay count: {}", count);
    }
}
